package main.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import main.dao.VoteOptionDAO;
import main.entity.VoteOptionVO;
import main.entity.VoteVO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("voteService")
public class VoteService extends BaseService<VoteVO> {
	
	@Autowired
	private VoteOptionDAO voteOptionDAO;
	
	public Map<String, Object> getResultByID(Integer voteID){
		VoteVO voteVO = getBaseDAO().getByID(VoteVO.class, voteID);
		@SuppressWarnings("unchecked")
		List<VoteOptionVO> optionVOs = (List<VoteOptionVO>) voteOptionDAO.getByVoteID(voteID);
		Map<String, Object>voteInfoMap = new HashMap<String, Object>();
		voteInfoMap.put("vote", voteVO);
		voteInfoMap.put("options", optionVOs);
		return voteInfoMap;
	}
/*	
	public Map<String, Object> readByID(Integer voteID){
		VoteVO voteVO = getBaseDAO().getByID(VoteVO.class, voteID);
		@SuppressWarnings("unchecked")
		List<VoteOptionVO> optionVOs = (List<VoteOptionVO>) voteOptionDAO.getByVoteID(voteID);
		for (VoteOptionVO voteOptionVO : optionVOs) {
			voteOptionVO.setTicketNum(0);//for secret
		}
		voteInfoMap.put("vote", voteVO);
		voteInfoMap.put("options", optionVOs);
		return voteInfoMap;
	}*/
	
}
